package com.java.netty.nio.netty.inboundhandlerandoutboundhandler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * @Author: Dgg
 * @Date: 2022/1/23 17:34
 */
public class MyServerInitializer extends ChannelInitializer<SocketChannel> {
	@Override
	protected void initChannel(SocketChannel ch) throws Exception {

		ChannelPipeline pipeline = ch.pipeline();

		//入栈handler 进行解码
		pipeline.addLast(new MyByteToLongDecoder());

		pipeline.addLast(new MyLongToByteEncoder());
		//自定义handler 处理业务逻辑
		pipeline.addLast(new MyServerHandler());
	}
}
